with Ada.Text_IO;
use Ada.Text_IO;

with Ada.Command_Line;
use Ada.Command_Line;

with Ada.Strings;
use Ada.Strings;

with Ada.Strings.Fixed;

procedure Main is
	X: String := "init";
	A, B : Integer := 0;
begin
	if Argument_Count < 2 then
		Put_Line("Requires two arguments - this is the test program for concatenating fixed strings");
		return;	
	end if;

	if Argument(1)'length <= X'length then
		X := Argument(1);
	else
		Put_Line("First argument is longer than placeholder variable.");
	end if;

	Put ("Arg 1 is ");
	Put_Line(X);
	A := X'length;

	-- belong to Ada.Strings.Fixed.
	Ada.Strings.Fixed.Move (
		Source => Argument(2),
		Target => X,
		-- Just including above causes error .. 
		-- raised ADA.STRINGS.LENGTH_ERROR : a-strfix.adb:367
		-- including the rest below addresses the issue.
		Drop    => Right,
		Justify => Left,
		Pad     => Space
	);

	Put ("Arg 2 is ");
	Put_Line(X);

	B := X'length;

	if A > B then
		Put(Argument(1));
		Put(" is longer than ");
		Put_Line(Argument(2));
	else 
		Put(Argument(2));
		Put(" is longer than ");
		Put_Line(Argument(1));
	end if;

	for I in Integer range 0 .. X'length loop
		Put_Line(X(X'first .. I));
	end loop;

	Put_Line("Fixed length arrays can be concatenated easily.");
	Put_Line(Argument(1) & Argument(2));

end Main;
